unit_test_v2.c

/*
 * Unit Test Bootstrap
 * Autor: Tomasz Jaworski, 2018-2019
 *
 * Test dla zadania Histogram
 * Autor testowanej odpowiedzi: Szymon Ptak
 * Test wygenerowano automatycznie o 2019-08-22 17:43:08.175216
 *
 * Debug: 
 */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <signal.h>
#include <setjmp.h>
#include <assert.h>

#define _RLDEBUG_API_
#include "unit_helper_v2.h"
#include "rdebug.h"

#include "tested_declarations.h"
#include "rdebug.h"

//
// Elementy globalne dla całego testu
//




//
//  Test 1: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST1(void)
{
    // informacje o teście
    test_start(1, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0};
                int output[] = {-1, -2, -2, 0, 0, 1, 1, -1, -2, -1, 1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){4.729185, 1.155416}, 2, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 11; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 2: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST2(void)
{
    // informacje o teście
    test_start(2, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {2, 2, 4, 1, 4, 3, 3, 4, 4, 3, 1};
                int output[] = {-1, 2, -2, 0, -2, -1, 0, 0, 1, -1, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){8.114225, 6.921113, 8.699701, 4.773726, 7.542710, 4.963745, 8.246828, 7.097966, 7.910816, 4.786168, 9.885821, 1.853731, 5.272428, 5.647309, 5.334303, 0.573159, 2.101472, 6.714298, 2.853334, 10.871536, 9.078632, 9.851276, 7.518679, 8.269480, 6.810027, 2.939511, 2.076295, 4.852178, 0.567366, 3.467849, 1.979481}, 31, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [2, 2, 4, 1, 4, 3, 3, 4, 4, 3, 1]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 11; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 3: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST3(void)
{
    // informacje o teście
    test_start(3, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {19, 16, 13, 12, 10, 14, 12, 13, 15, 12, 17};
                int output[] = {-1, -2, 0, 1, 1, 1, -1, 2, 1, -2, 1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){7.600387, 2.210033, 5.837370, 10.444909, 0.523808, 8.803495, 1.495503, 1.078428, 8.823147, 3.694917, 10.645188, 6.040522, 5.480727, 7.019694, 7.890508, 10.349443, 4.405543, 3.391741, 3.259031, 10.916206, 3.714681, 8.916539, 2.377885, 1.530245, 1.977178, 6.242632, 2.777228, 3.557970, 7.302841, 9.198634, 1.351817, 3.897126, 1.905738, 8.187553, 1.872165, 6.614652, 3.062378, 0.389372, 7.423355, 7.541578, 6.910936, 0.055680, 0.457815, 5.876232, 2.826019, 7.813906, 0.860721, 9.925086, 8.163426, 5.152129, 10.625633, 6.887763, 10.626828, 4.913238, 0.773063, 8.483745, 2.767199, 2.431172, 10.354678, 10.620168, 8.359698, 5.517429, 1.830704, 4.551699, 0.233172, 3.435456, 9.812093, 5.608906, 3.620694, 5.491513, 10.633672, 5.513718, 0.886023, 10.606858, 1.287031, 3.950048, 8.463518, 2.577878, 8.619218, 0.206857, 0.082651, 2.110483, 0.434209, 2.599456, 9.539771, 9.739747, 8.760311, 7.220105, 10.557326, 1.164324, 4.530157, 6.646837, 5.565562, 0.167119, 7.203651, 9.394448, 1.300234, 4.901401, 0.732718, 2.236998, 8.946202, 4.233841, 5.705916, 9.466128, 4.614144, 10.265807, 5.855907, 0.967728, 9.158559, 1.050401, 1.519771, 6.875705, 7.724041, 9.717770, 8.780001, 10.281073, 5.874758, 5.991629, 0.437730, 10.841888, 8.186840, 4.167203, 3.067353, 2.333238, 1.571720, 6.742831, 1.701206, 9.631380, 9.227834, 7.938456, 10.756614, 3.275369, 2.024352, 8.723940, 2.179091, 7.169215, 1.327725, 0.857469, 10.541677, 4.043215, 6.327127, 0.049146, 4.076721, 10.159604, 6.289172, 8.315948, 7.888073, 9.909968, 0.425378, 6.028891, 0.875269, 6.250316, 5.064570}, 153, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [19, 16, 13, 12, 10, 14, 12, 13, 15, 12, 17]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 11; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 4: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST4(void)
{
    // informacje o teście
    test_start(4, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {0, 1, 0, 0, 0, 1, 0, 2, 0, 0, 0};
                int output[] = {-2, 0, 2, 1, -2, -2, 0, -1, 2, 2, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){-2.771387, -8.418969, 7.102892, 5.303962, 7.817306, 1.767821}, 6, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [0, 1, 0, 0, 0, 1, 0, 2, 0, 0, 0]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 11; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 5: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST5(void)
{
    // informacje o teście
    test_start(5, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {4, 5, 8, 1, 4, 4, 1, 7, 4, 2, 0};
                int output[] = {-1, 1, 1, -1, 2, -2, 1, 1, 2, 0, 0};
        
                printf("#####START#####");
                int res = create_histogram((float[]){-3.019670, -1.995887, 2.722957, 8.329829, 5.464013, 2.710202, -2.818740, 9.218459, -8.357086, -7.681029, -5.356704, -9.990373, 0.222313, 5.387422, -8.723921, -8.349510, 7.183711, -8.824437, -9.435755, -4.430545, 2.772095, -3.215453, 8.833164, 1.823445, 7.457190, -2.490045, 4.760207, -9.806239, 0.355768, -0.088447, 1.459308, 2.160772, 4.999597, 2.809333, 2.684823, 0.711949, -4.671266, -8.359087, -4.596930, -9.288569, 1.947683, -4.244934, -6.005422, 7.592773, -1.838248, 5.840839, -2.875982, -0.757368, -8.312992, 1.021709, -9.798412, 4.505413, -6.505898, 0.886072, 2.020809, -9.223654, -3.742963, 4.102758, -1.685282, -4.380237, 9.751892, -1.615361, 2.627427, 8.096514, -7.884629, 6.197043, 7.466273, -4.455579, 8.723873, -0.654058, 1.456967, -0.853949, -8.027857, -2.261331, -5.757793, 3.330929, -4.140512, 7.326789, -4.496412, 5.067378, 7.344538, -4.345480, 7.115083}, 83, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [4, 5, 8, 1, 4, 4, 1, 7, 4, 2, 0]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 11; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 6: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST6(void)
{
    // informacje o teście
    test_start(6, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {5, 6, 4, 7, 5, 6, 6, 3, 3, 3, 8, 7, 6, 3, 3, 5, 5, 6, 2, 5, 0};
                int output[] = {0, 2, -2, -1, 0, -2, -1, 0, 1, -2, 1, 1, 1, -2, 2, 2, -1, 1, 1, 0, -2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){5.600360, 3.823673, 17.155080, 12.255309, 6.949810, 9.201744, 4.533384, 2.105307, 11.930220, 11.264158, 6.905240, 16.311630, 3.639906, 5.910797, 10.421391, 15.750092, 13.309017, 13.693642, 1.723501, 2.382218, 5.487288, 7.569506, 1.693787, 2.970339, 3.221902, 10.147242, 8.531420, 0.610102, 11.417166, 6.487323, 7.630650, 6.187633, 11.387567, 1.413165, 0.814390, 14.611588, 10.951531, 11.477763, 15.012981, 13.307650, 5.719888, 1.669864, 16.904023, 5.622265, 9.041488, 16.899856, 17.162343, 6.712170, 9.385896, 1.211944, 12.962058, 8.472835, 19.833645, 19.499995, 16.696222, 17.512422, 17.034609, 15.846275, 15.752468, 4.675280, 7.407485, 19.384914, 0.633803, 12.903190, 0.992200, 3.571909, 19.654581, 4.766424, 4.460267, 6.196647, 3.477184, 0.879993, 15.031679, 19.091034, 14.440257, 18.600923, 10.321440, 8.248665, 11.822823, 12.836541, 4.937874, 18.828389, 16.662559, 10.731887, 2.579291, 10.226928, 17.219976, 11.484336, 17.668251, 3.706727, 10.306311, 1.713039, 3.446501, 12.717749, 12.427955, 5.301444, 10.174179, 14.838931}, 98, output, 21);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 21; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [5, 6, 4, 7, 5, 6, 6, 3, 3, 3, 8, 7, 6, 3, 3, 5, 5, 6, 2, 5, 0]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 21; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 7: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST7(void)
{
    // informacje o teście
    test_start(7, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {14, 8, 9, 12, 10, 11, 7, 10, 17, 18, 16, 5, 7, 11, 11, 12, 7, 16, 5, 11, 11, 9, 9, 12, 8, 3, 10, 3, 8, 12, 13, 13, 11, 10, 8, 6, 5, 11, 8, 8, 9, 16, 6, 7, 11, 7, 8, 10, 10, 13, 17, 11, 13, 9, 11, 0};
                int output[] = {-2, -1, 2, 1, -1, -2, 0, 1, 0, 1, -2, 1, 1, 1, 1, -1, 2, -1, 2, -2, -1, 0, 2, 0, 0, -1, -2, -1, 0, 2, 2, -1, 2, 1, -1, -2, 0, 2, 2, 0, -1, 2, -2, 0, 2, -2, 2, 2, 0, -1, -2, 2, 1, -1, -2, 2};
        
                printf("#####START#####");
                int res = create_histogram((float[]){20.817341, 50.923069, 48.418444, 48.794235, 31.631582, 20.124215, 21.592527, 22.334903, 24.141766, 17.981945, 53.818395, 51.335883, 2.350216, 24.835861, 4.382130, 1.652368, 8.786976, 16.219241, 2.567421, 14.831840, 5.999422, 46.720094, 41.597844, 53.386321, 21.270236, 54.010436, 33.869767, 39.645667, 29.910209, 49.212598, 33.275661, 10.490634, 32.101054, 12.844704, 7.355453, 6.744979, 47.528052, 39.941681, 26.208935, 7.284800, 41.386130, 5.159020, 1.075421, 33.773550, 43.889982, 28.131559, 9.831981, 37.477918, 3.208189, 38.011900, 17.592816, 43.486274, 50.779516, 13.043526, 0.918708, 8.985081, 53.437702, 19.477282, 54.394382, 1.458864, 13.985281, 48.040365, 38.509037, 10.003876, 33.026054, 5.575423, 40.138442, 35.604715, 30.655165, 14.215265, 50.553868, 9.587415, 26.003070, 17.455788, 7.396608, 37.739137, 21.054985, 16.646325, 45.468526, 43.809914, 41.752279, 45.177414, 37.366793, 38.463514, 26.300764, 24.299498, 49.970483, 50.486269, 9.430724, 6.681300, 3.616270, 8.129076, 53.235315, 53.513635, 12.519167, 44.357197, 44.216538, 32.152633, 10.213307, 30.773848, 17.308559, 5.115420, 47.445236, 20.331985, 3.968716, 49.517620, 15.263201, 50.289468, 54.655439, 49.939591, 26.563890, 6.524394, 41.661656, 50.303966, 19.677953, 17.216702, 15.083788, 26.490644, 48.354451, 15.472559, 37.055519, 3.693909, 29.334234, 2.761380, 1.777026, 54.433500, 8.052757, 8.288264, 31.341704, 40.260823, 30.199379, 37.468818, 19.239874, 38.562159, 35.045142, 28.251619, 33.287391, 54.812134, 37.030615, 49.875189, 20.342126, 18.198656, 24.264881, 8.768642, 20.135053, 48.821990, 5.548361, 26.157657, 32.413307, 2.819548, 10.262378, 3.404105, 0.075027, 50.396653, 15.043807, 5.377927, 3.498592, 42.583138, 2.941708, 0.693976, 36.857139, 15.743125, 17.645579, 50.456711, 9.363698, 49.051353, 37.735844, 40.601834, 45.935828, 8.839616, 32.157518, 47.550139, 31.661701, 52.730944, 5.646202, 43.198498, 4.538490, 8.659904, 49.303661, 3.185487, 22.751239, 20.545058, 12.530832, 34.134984, 8.137469, 19.662532, 10.097892, 23.256335, 23.107151, 32.528150, 31.441343, 44.164137, 31.349208, 40.238267, 53.281926, 47.399035, 54.352643, 19.166047, 49.701793, 15.439077, 44.579132, 20.079959, 43.911186, 5.382153, 28.318114, 46.303153, 35.504601, 4.453759, 4.081144, 23.209862, 49.539315, 32.918697, 32.578955, 13.300274, 9.888127, 8.752382, 0.323808, 51.659686, 2.512751, 10.623855, 46.624777, 15.966192, 52.701299, 42.539033, 25.892065, 23.607496, 3.952696, 10.385204, 17.926207, 9.961842, 11.100647, 15.387285, 30.708622, 5.733918, 51.514868, 52.708756, 30.470682, 43.690221, 50.558636, 41.238145, 5.752488, 10.323033, 21.752252, 22.957380, 48.186963, 47.298144, 41.915050, 28.435599, 19.977511, 47.669965, 15.468771, 10.126216, 41.344366, 39.423120, 41.833036, 24.864426, 46.640655, 36.355898, 29.093284, 47.411946, 13.453500, 11.778684, 54.495273, 14.481416, 30.495031, 16.071057, 21.069534, 22.146010, 20.057008, 34.413232, 49.158124, 52.203523, 39.162910, 9.860961, 41.954436, 22.160767, 32.454145, 15.721874, 32.241981, 20.630547, 34.145209, 14.821800, 8.252729, 50.144008, 41.273428, 41.303463, 34.299917, 13.670549, 1.623637, 22.784117, 42.270252, 44.796349, 3.283671, 0.079096, 27.139933, 10.614158, 15.669500, 44.350673, 8.864350, 54.056742, 13.107563, 6.174110, 17.181815, 4.531011, 41.669313, 42.727622, 38.345703, 47.486646, 38.098654, 31.383135, 51.421345, 31.821571, 1.930220, 3.806367, 14.900288, 51.195586, 28.658862, 4.476039, 12.965895, 23.478380, 29.795269, 18.472367, 52.932819, 34.857748, 37.871057, 51.177782, 13.316760, 44.968182, 52.466309, 9.936910, 18.665104, 34.128925, 50.611283, 14.283806, 25.014446, 10.839726, 2.546127, 22.086343, 18.716989, 10.382527, 2.072824, 41.871090, 19.697955, 33.587113, 10.287148, 24.560165, 4.328942, 37.754099, 48.305556, 23.601096, 44.070381, 48.783531, 17.567223, 0.979580, 28.081762, 51.147531, 35.068281, 36.930985, 5.918009, 27.190204, 41.944345, 29.339998, 3.880707, 14.384647, 14.202860, 9.268592, 12.120916, 33.503459, 31.262786, 44.292802, 13.822471, 41.076063, 52.492787, 21.996318, 23.973834, 32.848281, 9.178486, 30.719978, 0.410713, 29.883783, 9.443758, 35.490590, 43.732996, 0.333836, 17.388002, 49.329257, 17.587332, 13.465416, 9.668582, 52.863849, 8.982868, 8.711009, 39.230067, 34.656655, 22.049153, 46.077118, 10.266225, 36.273260, 32.630618, 25.470101, 31.882229, 47.399182, 38.006333, 23.082845, 29.144175, 29.955680, 40.696200, 48.478505, 14.846312, 30.753379, 31.003786, 7.821918, 17.326008, 51.464341, 30.805473, 39.718728, 16.502892, 7.328884, 16.169582, 44.035385, 23.239411, 3.070169, 45.602006, 10.071674, 16.107544, 24.703704, 17.154607, 28.779331, 4.673585, 20.839266, 17.393213, 29.958758, 9.939567, 45.579924, 21.194597, 45.358219, 7.118267, 39.427086, 9.165341, 19.529253, 53.268179, 7.630088, 0.102768, 52.684496, 31.225182, 2.934996, 6.952663, 50.235638, 9.982761, 20.635418, 40.014548, 1.785369, 18.257608, 31.884959, 0.401571, 14.147089, 51.564155, 17.333307, 14.742023, 23.879850, 49.036910, 50.221428, 9.953376, 11.742327, 53.071239, 12.019930, 30.542650, 47.698182, 33.753646, 52.165109, 26.761695, 50.485230, 34.736711, 51.347249, 10.427083, 23.335823, 21.724093, 17.086107, 39.062834, 22.261386, 54.733655, 30.063195, 13.816542, 50.149581, 54.333303, 29.825276, 19.963343, 50.034697, 51.586005, 27.242623, 4.888011, 4.046282, 16.622197, 9.512187, 33.281816, 26.578814, 29.038955, 52.168145, 52.234450, 7.278042, 38.218671, 53.425456, 8.134145, 31.739661, 8.049035, 46.233881, 6.817608, 7.079895, 0.951947, 29.003466, 46.540593, 12.668214, 21.288516, 45.690856, 33.936394, 54.149591, 30.703452, 0.452634, 37.132448, 7.751387, 52.042463, 1.267881, 26.923324, 19.723998, 41.226053, 46.419975, 26.688772, 44.609063, 40.272249, 37.309386, 6.364191, 11.591453, 40.493041, 36.232314, 23.291454, 35.984729, 42.417417, 28.011524, 13.034738, 30.585766, 48.058138, 19.135531, 40.296125, 0.305465, 8.312476, 11.084445, 50.659148, 24.524520, 9.279121, 49.338610, 0.623753, 42.708482, 15.183014}, 553, output, 56);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 56; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [14, 8, 9, 12, 10, 11, 7, 10, 17, 18, 16, 5, 7, 11, 11, 12, 7, 16, 5, 11, 11, 9, 9, 12, 8, 3, 10, 3, 8, 12, 13, 13, 11, 10, 8, 6, 5, 11, 8, 8, 9, 16, 6, 7, 11, 7, 8, 10, 10, 13, 17, 11, 13, 9, 11, 0]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 56; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 8: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST8(void)
{
    // informacje o teście
    test_start(8, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {7, 4, 2, 6, 3, 5, 5, 9, 4};
                int output[] = {-2, 0, 0, -1, -1, 2, 1, 2, 1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){0.544180, 9.981425, 2.753778, 10.793380, 7.307990, 10.936134, 4.165523, 3.068538, 7.929476, 10.575563, 1.589997, 0.825479, 8.301280, 7.525749, 4.881349, 3.233531, 7.849527, 0.516648, 0.092586, 4.553337, 7.577426, 10.983736, 3.088048, 5.271876, 7.664290, 5.816678, 1.094905, 8.906105, 6.654365, 9.958029, 1.096301, 5.736638, 0.279158, 8.657164, 3.670908, 1.585397, 3.172503, 6.835641, 6.014193, 6.243966, 2.780411, 9.235586, 7.142808, 10.992991, 6.244001, 3.675612, 5.548462, 7.290161, 8.711972, 0.058032, 0.997666, 5.057073, 7.600400}, 53, output, 9);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 9; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [7, 4, 2, 6, 3, 5, 5, 9, 4]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 9; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 9: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST9(void)
{
    // informacje o teście
    test_start(9, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
                int output[] = {0, -1, 2, 1, 0, -1, -2, -2, -2, -1, -1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){10.191848}, 1, output, 11);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 11; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 11; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 10: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST10(void)
{
    // informacje o teście
    test_start(10, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    
        
                const int expected_array[] = {3};
                int output[] = {-1};
        
                printf("#####START#####");
                int res = create_histogram((float[]){2.237135, 7.457946, 4.414613, 2.742458, 4.654678, 4.838624, 9.610191, 0.660315, 3.589389, 8.998872, 8.238696, 8.194112, 4.079743, 8.492262, 6.884576, 8.777540, 4.115004, 2.943588, 3.578938, 5.932575, 9.043958, 6.721318, 10.279049, 1.137771, 2.877444, 3.823215, 10.418620, 3.761589, 2.686649, 8.128337, 9.043429, 4.857545, 9.392144, 1.423646, 5.698068, 7.681504, 6.971523, 4.315652, 6.924281, 10.272272, 2.067363, 8.461817, 5.097046, 4.915947, 0.998137, 10.932758, 5.073995, 3.023222, 7.213575, 2.708851, 1.417129, 6.447681, 6.200380, 9.935353, 2.487752, 6.011428, 5.675465, 8.892555, 6.971872, 7.064986, 7.676877, 8.572763, 3.471690, 4.066538, 5.833978, 5.431168, 8.733011, 1.632703, 5.661987, 8.750179, 6.045806, 9.765696, 7.335935, 8.551317, 6.760529, 2.322302, 4.838866, 3.302270, 7.612037, 1.430480, 6.686197, 2.719578, 3.371475, 7.213055, 1.160016, 9.509527, 8.245369, 6.944611, 5.845226, 6.341316, 5.364025, 9.135278, 8.510375, 5.772122, 1.735759, 3.167709, 9.336714, 0.872618, 3.616321}, 99, output, 1);
                printf("#####END#####");
                test_error(res == 0, "Funkcja create_histogram() powinna zwrócić 0, a zwróciłą %d", res);


                int ok = 0;        
                for (int i = 0; i < 1; ++i)
                    ok += output[i] != expected_array[i];
                    
                if (ok)
                {         
                    printf("Powinno być: [3]\n");

                    printf("\nTablica po wywołaniu funkcji create_histogram: ");

                    for (int i = 0; i < 1; ++i)
                        printf("%d ", output[i]);            

                    printf("\n");

                    test_error(ok == 0, "Funkcja create_histogram() niepoprawnie wypełniła tablicę");
                }


            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 11: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST11(void)
{
    // informacje o teście
    test_start(11, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            printf("#####START#####");
            int res = create_histogram((float[]){4.729185, 1.155416}, 12, NULL, 18);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 12: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST12(void)
{
    // informacje o teście
    test_start(12, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int output[] = {-2, 1, -1, -2, -2, -1, -1, -2, 1, -1, 1};

            printf("#####START#####");
            int res = create_histogram(NULL, 15, output, 10);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 13: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST13(void)
{
    // informacje o teście
    test_start(13, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int output[] = {-2, 1, -1, -2, -2, -1, -1, -2, 1, -1, 1};

            printf("#####START#####");
            int res = create_histogram((float[]){4.729185, 1.155416}, 0, output, 19);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 14: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST14(void)
{
    // informacje o teście
    test_start(14, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int output[] = {-2, 1, -1, -2, -2, -1, -1, -2, 1, -1, 1};

            printf("#####START#####");
            int res = create_histogram((float[]){4.729185, 1.155416}, 17, output, 0);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 15: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST15(void)
{
    // informacje o teście
    test_start(15, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int output[] = {-2, 1, -1, -2, -2, -1, -1, -2, 1, -1, 1};

            printf("#####START#####");
            int res = create_histogram((float[]){4.729185, 1.155416}, -13, output, 13);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 16: Sprawdzanie poprawności działania funkcji create_histogram
//
void UTEST16(void)
{
    // informacje o teście
    test_start(16, "Sprawdzanie poprawności działania funkcji create_histogram", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int output[] = {-2, 1, -1, -2, -2, -1, -1, -2, 1, -1, 1};

            printf("#####START#####");
            int res = create_histogram((float[]){4.729185, 1.155416}, 10, output, -18);
            printf("#####END#####");
            test_error(res == 1, "Funkcja create_histogram() powinna zwrócić 1, a zwróciłą %d", res);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 17: Sprawdzanie poprawności działania funkcji display
//
void UTEST17(void)
{
    // informacje o teście
    test_start(17, "Sprawdzanie poprawności działania funkcji display", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    


                int tab[] = {0, -6, -3, 1, 7, -6, 1, 8};

        //-------------1-----------------------
                printf("\n***TEST 1***\n\n");
                printf("***START***\n");
                display_vector(tab, 0);
                printf("***END***\n");


        //-------------2-----------------------

                printf("\n***TEST 2***\n\n");
                printf("***START***\n");
                display_vector(tab, -8);
                printf("***END***\n");

        //-------------3-----------------------

                printf("\n***TEST 3***\n\n");
                printf("***START***\n");
                display_vector(tab, 8);
                printf("***END***\n");

        //-------------4-----------------------

                printf("\n***TEST 4***\n\n");
                printf("***START***\n");
                display_vector(tab, 8 - 1);
                printf("***END***\n");

            onerror_terminate(); // przerwanie wszystkich testów jednostkowych (np. coś jest mocno nie tak z kodem)

            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 18: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST18(void)
{
    // informacje o teście
    test_start(18, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    


                const int expected_result = 9;
                const float expected_array[] = {5.000000, -2.000000, 3.000000, 1.000000, -9.000000, 5.000000, -10.000000, -8.000000, 1.000000, 0.000000};
                float dest[10]; 
                int result = read_vector_float(dest, 10, 0);           

                test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
                int ok = 0;
                for (int i = 0; i < expected_result; ++i)
                    ok += !(expected_array[i] + 0.001 >= dest[i] && expected_array[i] - 0.001 <= dest[i]);

                test_error(ok == 0, "Funkcja read_vector_float() niepoprawnie pobrałá dane od użytkownika");
                if (ok)
                {
                    printf("Powinno być: [5.000000, -2.000000, 3.000000, 1.000000, -9.000000, 5.000000, -10.000000, -8.000000, 1.000000, 0.000000]\n");
                    printf("Jest: [");
                    for (int i = 0; i < expected_result - 1; ++i)
                        printf("%f, ", dest[i]);

                    printf("%f] ", dest[expected_result - 1]);

                }

            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 19: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST19(void)
{
    // informacje o teście
    test_start(19, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    


                const int expected_result = 7;
                const float expected_array[] = {-2.000000, -8.000000, -6.000000, 0.000000, 5.000000, 2.000000, 1.000000, -9.000000};
                float dest[8]; 
                int result = read_vector_float(dest, 8, -9);           

                test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
                int ok = 0;
                for (int i = 0; i < expected_result; ++i)
                    ok += !(expected_array[i] + 0.001 >= dest[i] && expected_array[i] - 0.001 <= dest[i]);

                test_error(ok == 0, "Funkcja read_vector_float() niepoprawnie pobrałá dane od użytkownika");
                if (ok)
                {
                    printf("Powinno być: [-2.000000, -8.000000, -6.000000, 0.000000, 5.000000, 2.000000, 1.000000, -9.000000]\n");
                    printf("Jest: [");
                    for (int i = 0; i < expected_result - 1; ++i)
                        printf("%f, ", dest[i]);

                    printf("%f] ", dest[expected_result - 1]);

                }

            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 20: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST20(void)
{
    // informacje o teście
    test_start(20, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    


                const int expected_result = 0;
                const float expected_array[] = {0.000000};
                float dest[5]; 
                int result = read_vector_float(dest, 5, 0);           

                test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
                int ok = 0;
                for (int i = 0; i < expected_result; ++i)
                    ok += !(expected_array[i] + 0.001 >= dest[i] && expected_array[i] - 0.001 <= dest[i]);

                test_error(ok == 0, "Funkcja read_vector_float() niepoprawnie pobrałá dane od użytkownika");
                if (ok)
                {
                    printf("Powinno być: [0.000000]\n");
                    printf("Jest: [");
                    for (int i = 0; i < expected_result - 1; ++i)
                        printf("%f, ", dest[i]);

                    printf("%f] ", dest[expected_result - 1]);

                }

            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 21: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST21(void)
{
    // informacje o teście
    test_start(21, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    


                const int expected_result = 3;
                const float expected_array[] = {9.000000, 4.000000, 7.000000};
                float dest[3]; 
                int result = read_vector_float(dest, 3, -7);           

                test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
                int ok = 0;
                for (int i = 0; i < expected_result; ++i)
                    ok += !(expected_array[i] + 0.001 >= dest[i] && expected_array[i] - 0.001 <= dest[i]);

                test_error(ok == 0, "Funkcja read_vector_float() niepoprawnie pobrałá dane od użytkownika");
                if (ok)
                {
                    printf("Powinno być: [9.000000, 4.000000, 7.000000]\n");
                    printf("Jest: [");
                    for (int i = 0; i < expected_result - 1; ++i)
                        printf("%f, ", dest[i]);

                    printf("%f] ", dest[expected_result - 1]);

                }

            
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 22: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST22(void)
{
    // informacje o teście
    test_start(22, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int expected_result = -1;
            float dest[6]; 
            printf("#####START#####");
            int result = read_vector_float(dest, 0, -7);           
            printf("#####END#####");

            test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 23: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST23(void)
{
    // informacje o teście
    test_start(23, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int expected_result = -1;
            float dest[10]; 
            printf("#####START#####");
            int result = read_vector_float(dest, -6, -5);           
            printf("#####END#####");

            test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}

//
//  Test 24: Sprawdzanie poprawności działania funkcji read_vector_float
//
void UTEST24(void)
{
    // informacje o teście
    test_start(24, "Sprawdzanie poprawności działania funkcji read_vector_float", __LINE__);

    // uwarunkowanie zasobów - pamięci, itd...
    test_file_write_limit_setup(33554432);
    rldebug_reset_limits();
    
    //
    // -----------
    //
    

            int expected_result = -1; 
            printf("#####START#####");
            int result = read_vector_float(NULL, -9, -4);           
            printf("#####END#####");

            test_error(result == expected_result, "Funkcja read_vector_float() powinna zwrócić %d, a zwróciła %d", expected_result, result);
        
    //
    // -----------
    //

    // przywrócenie podstawowych parametów przydzielania zasobów (jeśli to tylko możliwe)
    rldebug_reset_limits();
    test_file_write_limit_restore();
    
    test_ok();
}




enum run_mode_t { rm_normal_with_rld = 0, rm_unit_test = 1, rm_main_test = 2 };

int __wrap_main(volatile int _argc, char** _argv, char** _envp)
{
    int volatile vargc = _argc;
    char ** volatile vargv = _argv, ** volatile venvp = _envp;
    volatile enum run_mode_t run_mode = rm_unit_test; // -1
    volatile int selected_test = -1;

    if (vargc > 1)
    {
        char* smode = strtok(vargv[1], ",");
        char* stest = strtok(NULL, "");
        char *errptr = NULL;
        run_mode = (enum run_mode_t)strtol(smode, &errptr, 10);
        if (*errptr == '\x0')
        {
            memmove(vargv + 1, vargv + 2, sizeof(char*) * (vargc - 1));
            vargc--;

            if (stest != NULL)
            {
                int val = (int)strtol(stest, &errptr, 10);
                if (*errptr == '\x0')
                    selected_test = val;
            }
        }
    }

    // printf("runmode=%d; selected_test=%d\n", run_mode, selected_test);

    // inicjuj testy jednostkowe
    unit_test_init(run_mode, "unit_test_v2.c");
    test_limit_init();
    rldebug_set_reported_severity_level(MSL_FAILURE);

    if (run_mode == rm_normal_with_rld)
    {
        // konfiguracja ograniczników
        rldebug_reset_limits();
        

        // uruchom funkcję main Studenta a potem wyświetl podsumowanie sterty i zasobów
        volatile int ret_code = rdebug_call_main(tested_main, vargc, vargv, venvp);

        rldebug_reset_limits();
        

        int leaks_detected = rldebug_show_leaked_resources(0);
        if (leaks_detected)
            raise(SIGHEAP);

        return ret_code;
    }

    
    if (run_mode == rm_unit_test)
    {
        test_title("Testy jednostkowe");

        void (*pfcn[])(void) =
        { 
            UTEST1, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST2, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST3, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST4, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST5, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST6, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST7, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST8, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST9, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST10, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST11, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST12, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST13, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST14, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST15, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST16, // Sprawdzanie poprawności działania funkcji create_histogram
            UTEST17, // Sprawdzanie poprawności działania funkcji display
            UTEST18, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST19, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST20, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST21, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST22, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST23, // Sprawdzanie poprawności działania funkcji read_vector_float
            UTEST24, // Sprawdzanie poprawności działania funkcji read_vector_float
            NULL
        };

        for (int idx = 0; pfcn[idx] != NULL && !test_get_session_termination_flag(); idx++)
        {
            if (selected_test == -1 || selected_test == idx + 1)
                pfcn[idx]();

            // limit niezaliczonych testów, po jakim testy jednostkowe zostaną przerwane
            if (test_session_get_fail_count() >= 1000)
                test_terminate_session();
        }


        test_title("RLDebug :: Analiza wycieku zasobów");
        // sprawdź wycieki pamięci
        int leaks_detected = rldebug_show_leaked_resources(1);
        test_set_session_leaks(leaks_detected);

        // poinformuj serwer Mrówka o wyniku testu - podsumowanie
        test_title("Podsumowanie");
        if (selected_test == -1)
            test_summary(24); // wszystkie testy muszą zakończyć się sukcesem
        else
            test_summary(1); // tylko jeden (selected_test) test musi zakończyć się sukcesem
        return EXIT_SUCCESS;
    }
    

    if (run_mode == rm_main_test)
    {
        test_title("Testy funkcji main()");

        void (*pfcn[])(int, char**, char**) =
        { 
            NULL
        };

        for (volatile int idx = 0; pfcn[idx] != NULL && !test_get_session_termination_flag(); idx++)
        {
            if (selected_test == -1 || selected_test == idx + 1)
                pfcn[idx](vargc, vargv, venvp);

            // limit niezaliczonych testów, po jakim testy jednostkowe zostaną przerwane
            if (test_session_get_fail_count() >= 1000)
                test_terminate_session();
        }


        test_title("RLDebug :: Analiza wycieku zasobów");
        // sprawdź wycieki pamięci
        int leaks_detected = rldebug_show_leaked_resources(1);
        test_set_session_leaks(leaks_detected);

        // poinformuj serwer Mrówka o wyniku testu - podsumowanie
        test_title("Podsumowanie");
        if (selected_test == -1)
            test_summary(0); // wszystkie testy muszą zakończyć się sukcesem
        else
            test_summary(1); // tylko jeden (selected_test) test musi zakończyć się sukcesem

        return EXIT_SUCCESS;
    }

    printf("*** Nieznana wartość RunMode: %d", (int)run_mode);
    abort();
}